﻿using GameFramework.Resource;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityGameFramework.Runtime;

namespace Cheng
{
    public static class ResourceExtension
    {

        ///// <summary>
        ///// 加载状态表
        ///// </summary>
        ///// <param name="resource"></param>
        ///// <param name="statusname"></param>
        ///// <returns></returns>
        //public static void LoadStatusConfigObject(this ResourceComponent resource,string statusname,CombatEntity CombatEntity)
        //{
            
        //    resource.LoadAsset(AssetUtility.GetStatusAsset(statusname), Constant.AssetPriority.EffectAsset, new LoadAssetCallbacks(
        //    (assetName, asset, duration, userData) =>
        //    {
        //        Type passive = Type.GetType("Status"+ statusname);
               
        //        var config = (StatusConfigObject)asset;
        //        var Status = (StatusAbility)EGamePlay.Entity.CreateWithParent(passive, CombatEntity, config);
        //        if (!CombatEntity.TypeIdStatuses.ContainsKey(Status.StatusConfigObject.ID))
        //        {
        //            CombatEntity.TypeIdStatuses.Add(Status.StatusConfigObject.ID, new List<StatusAbility>());
        //        }
        //        CombatEntity.TypeIdStatuses[Status.StatusConfigObject.ID].Add(Status);
        //        Status.OwnerEntity = CombatEntity;
        //        Status.TryActivateAbility();
        //        Log.Warning("Load Status '{0}' OK.", assetName);
             
             
        //    },

        //    (assetName, status, errorMessage, userData) =>
        //    {
        //        Log.Error("Can not load Status from '{0}' with error message '{1}'.", assetName, errorMessage);
        //    }));
           
        //}
       
        //public static void LoadSkillConfigObject(this ResourceComponent resource,string id,  string skillname, CombatEntity CombatEntity)
        //{
           
        //    resource.LoadAsset(AssetUtility.GetSkillAsset(id.ToString(), skillname), Constant.AssetPriority.EffectAsset, new LoadAssetCallbacks(
        //      (assetName, asset, duration, userData) =>
        //      {
        //          SkillConfigObject config = (SkillConfigObject)asset;
        //          SkillAbility ability = CombatEntity.AttachSkill<SkillAbility>(config);
        //          CombatEntity.BindSkillInput(ability, KeyCode.Q);
        //          ability.Name = config.Name;
        //          Log.Warning("Load skill '{0}' OK.", assetName);
        //      },

        //      (assetName, status, errorMessage, userData) =>
        //      {
        //          Log.Error("Can not load skill from '{0}' with error message '{1}'.", assetName, errorMessage);
        //      }));

           
        //}

    }
    
}